package com.example.arithmeticleetcode.leetcode;

import java.math.BigDecimal;
import java.time.*;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @program: arithmetic-leetcode
 * @description: 1464. 数组中两元素的最大乘积
 * @author: FangZhen
 * @create: 2020-06-09 15:01
 **/
public class Demo27 {

    public static void main(String[] args) {
//        testBoolean("haha", true);
//
//        int a = 1;
//        int b = 2;
//        int i = Math.floorDiv(a, b);
//        System.out.println(i);
//        int c = (a/b) * 100;
//        System.out.println(c);
//        System.out.println((a*100)/(b*100));
//        BigDecimal a1 = BigDecimal.valueOf(a);;
//        BigDecimal b1 = BigDecimal.valueOf(b);;
//        System.out.println(b1.divide(a1));
//        System.out.println("====");
//        BigDecimal.valueOf(a);
//        System.out.println(a1.divide(b1).multiply(new BigDecimal(100)).compareTo(new BigDecimal(50)));
//        System.out.println(a1.divide(b1).multiply(new BigDecimal(100)));
//        System.out.println(a1.divide(b1).multiply(new BigDecimal(100)).compareTo(new BigDecimal(51)) < 0);

        Map<String, String> map = new HashMap<>();
        map.put("a", "10");
//        boolean checkPartFlag = BigDecimal.valueOf(1).divide(BigDecimal.valueOf(3)).multiply(BigDecimal.valueOf(100)).compareTo(new BigDecimal(map.get("a"))) < 0;
        BigDecimal divide = BigDecimal.valueOf(1).divide(BigDecimal.valueOf(3), 2, BigDecimal.ROUND_HALF_UP);
        System.out.println(divide);
        System.out.println(BigDecimal.valueOf(1).divide(BigDecimal.valueOf(3), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)));
        System.out.println(new BigDecimal(map.get("a")));
//        System.out.println(BigDecimal.valueOf(1).divide(BigDecimal.valueOf(0),2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).compareTo(new BigDecimal(map.get("a"))) < 0);
        System.out.println("========================");
        Integer a = new Integer(1);
        int b = 1;
        System.out.println(Objects.equals(a, b));

        String str = "abd";
        System.out.println(str.concat("aaa"));

        LocalDate today = LocalDate.now();
        System.out.println("today's local date : " + today);

        Date date = new Date();
        System.out.println(date);

        int year = today.getYear();
        int month = today.getMonthValue();
        int day = today.getDayOfMonth();
        System.out.printf("Year: %d Month ：%d day : %d  t %n", year, month, day);

        System.out.println("--------------------------");
        LocalDate localDate = LocalDate.of(2021, 6, 10);
        System.out.println("The specil date is : " + localDate);

        if (localDate.equals(today)) {
            System.out.printf("TODAY %s and date1 %s are sanme date %n", today, localDate);
        }

        System.out.println("+++++++++++++++++++++++++++");
        MonthDay monthDay = MonthDay.of(localDate.getMonth(), localDate.getDayOfMonth());
        MonthDay monthDay1 = MonthDay.from(today);
        if (monthDay1.equals(monthDay)) {
            System.out.println("Happy birthday to you");
        } else {
            System.out.println("wait");
        }

        LocalTime localTime = LocalTime.now();
        System.out.println("local time now : " + localTime);

        LocalTime localTime1 = localTime.plusHours(2);
        System.out.println("Time after 2 hours : " + localTime1);

        LocalDate localDate1 = today.plus(1, ChronoUnit.WEEKS);
        System.out.println("Date after 1 week : " + localDate1);

        LocalDate localDate2 = today.minus(1, ChronoUnit.YEARS);
        System.out.println("Date before 1 year : " + localDate2);

        LocalDate plus = today.plus(1, ChronoUnit.YEARS);
        System.out.println("Date after 1 year : " + plus);

        Clock clock = Clock.systemUTC();
        System.out.println("clock : " + clock);

        Clock systemDefaultZone = Clock.systemDefaultZone();
        System.out.println("Clock : " + systemDefaultZone);

        LocalDate tomorrow = LocalDate.of(2020, 6, 11);
        if (tomorrow.isAfter(today)) {
            System.out.println("Tomorrow comes after today");
        }

        LocalDate yesterday = today.minus(1, ChronoUnit.DAYS);
        if (yesterday.isBefore(today)) {
            System.out.println("yesterday is before today");
        }

        ZoneId america = ZoneId.of("America/New_York");
        LocalDateTime localDateTime = LocalDateTime.now();
        ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime, america);
        System.out.println("特定的日期和时间在特定时区：" + zonedDateTime);

        int[] nums = {3, 7};
        System.out.println(maxProduct(nums));

        System.out.println("=====================++++++++++++++++++++");
        int waitSum = 0;
        waitSum = 0 + 1;
        //招聘人数=招聘的总需求数-招聘统计的总入职数
        int recruitSum = 3 - 0;
        boolean checkFullFlag = recruitSum > 0 && BigDecimal.valueOf(waitSum).divide(BigDecimal.valueOf(recruitSum), 2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).compareTo(new BigDecimal(10)) < 0;
        System.out.println(checkFullFlag);
    }

    public static int maxProduct(int[] nums) {
        int length = nums.length;
        int maxValue = -1;
        for (int i = 0, len = length - 1; i < len; i++) {
            for (int j = i + 1; j < length; j++) {
                int value = (nums[i] - 1) * (nums[j] - 1);
                if (maxValue < value) {
                    maxValue = value;
                }
            }
        }
        System.out.println(maxValue);
        return maxValue;
    }

    public static void testBoolean(String msg, Boolean flag) {
        if (flag) {
            System.out.println("true" + msg);
        }
        System.out.println("false" + msg);
    }
}
